﻿using System;
using System.Windows.Controls;
using ShadeTree.Binding;
using ShadeTree.Binding.Drivers;
using ShadeTree.Binding.WPF;

namespace ShadeTree.WinForms.Tests.WPF
{
    public class WpfTextBoxHandler : IControlHandler
    {
        public bool Handles(object control)
        {
            return control is TextBox;
        }

        public bool IsChecked(object control)
        {
            throw new NotImplementedException();
        }

        public void Enter(object control, string text)
        {
            ((TextBox) control).Text = text;
            ControlDriverFactory.GetDriver(control).FireLostFocus();
        }

        public object GetValue(IScreenElement element)
        {
            return ((TextboxElement)element).BoundControl.Text;
        }
    }
}
